<div>
  <!-- 添加商品分类按钮 -->
  <el-button type="primary" @click="addCategories">添加分类</el-button>
  <!-- 商品分类主体表格 -->
  <el-table :data="categoriesData" style="width: 100%">
    <!-- 这里是复杂的树形table列 -->
    <!-- 这个列可以当 el-table-column 用，支持el-table-column组件的所有属性-->
    <!-- tree-key属性用于找子节点？ -->
    <!-- parent-key属性用于找父节点？ -->
    <el-table-tree-column
      tree-key="cat_id"
      parent-key="cat_pid"
      level-key="cat_level"
      prop="cat_name"
      label="分类名称"
      width="180"
    ></el-table-tree-column>

    <!-- 下面是简单的table列 -->
    <el-table-column prop="cat_deleted" label="是否有效" width="180">
      <template slot-scope="scope">
        <span>{{ scope.row.cat_deleted ? "否" : "是" }}</span>
      </template>
    </el-table-column>
    <el-table-column label="层级">
      <template slot-scope="scope">
        <span v-if="scope.row.cat_level==0">一级</span>
        <span v-else-if="scope.row.cat_level==1">二级</span>
        <span v-else>三级</span>
      </template>
    </el-table-column>
  </el-table>
  <!-- 添加商品分类弹窗 -->
  <el-dialog title="添加分类" :visible.sync="categoriesFormVisible">
    <el-form :model="form" label-width="80px">
      <el-form-item label="分类名称">
        <el-input v-model="form.name" class="shorterInput"></el-input>
      </el-form-item>
      <!-- 联级选择器 -->
      <el-form-item label="父级名称">
        <el-cascader
          v-model="value"
          :options="cascaderData"
          @change="handleChange"
          :props="cascaderProps"
        ></el-cascader>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="confirmAddcategories">确 定</el-button>
    </div>
  </el-dialog>
</div>
